//
// Created on 2024/5/1.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".

#include "ModelGenerator.h"
ModelGenerator* ModelGenerator::m_instance = NULL;

std::shared_ptr<ViewModel> ModelGenerator::generateModel(ViewModelTypeE type)
{
    switch(type) {
        case FLOW_ITEM_VIEW_MODEL:
            return generateFlowItemViewModel();
        case WATER_FLOW_VIEW_MODEL:
            return generateWaterFlowViewModel();
    }
}

std::shared_ptr<ViewModel> ModelGenerator::generateWaterFlowViewModel()
{
    auto waterflowViewModel = std::make_shared<WaterFlowViewModel>();
    waterflowViewModel->setStartPosition({.x = 0, .y = 0});
    waterflowViewModel->setSize({.width = 280, .height = 450});
    waterflowViewModel->setBackgroundColor(0xFFFF0000);
    return waterflowViewModel;
}

std::shared_ptr<ViewModel> ModelGenerator::generateFlowItemViewModel()
{
    auto flowItemViewModel = std::make_shared<FlowItemViewModel>();
    flowItemViewModel->setStartPosition({.x = 0, .y = 0});
    flowItemViewModel->setSize({.width = 250, .height = 100});
    flowItemViewModel->setBackgroundColor(0xFFFFFF00);
    return flowItemViewModel;
}

std::shared_ptr<ViewModel> ModelGenerator::PicassoModelWaterFlow(int childNo)
{
    auto waterflowViewModel = generateModel(WATER_FLOW_VIEW_MODEL);
    for(auto i = 0; i <childNo; i++){
        auto flowItemViewModel = generateModel(FLOW_ITEM_VIEW_MODEL);
        waterflowViewModel->addChild(flowItemViewModel);
    }
    return waterflowViewModel;
}